home *** CD-ROM | disk | FTP | other *** search
/ GFX Sensations 1 / Graphic Sensations - Volume 1.iso / tools / amiga / 3d_tools / rend10.lzh / REND1.0 / GraphicSubSystem / control.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-08  |  3.1 KB  |  115 lines

  1. /*
  2.  * Title:
  3.  *    control.c
  4.  *
  5.  * Authors:
  6.  *    Michael P. Schenck
  7.  *
  8.  * Purpose:
  9.  *    Control.c provides the management needed in opening and closing the 
  10.  *    renderer.  The opengraphics function takes the specifications for
  11.  *    the screen size, the colors used for the background and lines and
  12.  *    a path to the model library.  This path is preappended to the model
  13.  *     path specified in the requestmodel function (see database.c)
  14.  *    A non-zero error value is returned if the renderer could not be opened.
  15.  *    The closegraphics function provides a method for shuting down
  16.  *    the renderer.
  17.  *     
  18.  * Copyright Info:
  19.  *    Copyright (C) 1993, 1994 -- by Michael P. Schenck, 
  20.  *    (mps4466@ultb.isc.rit.edu)
  21.  *    
  22.  *    This program is free software; you can redistribute it and/or modify
  23.  *    it under the terms of the GNU General Public License as published
  24.  *    by the Free Software Foundation; either version 2 of the License,
  25.  *    or (at your option) any later version.
  26.  *
  27.  *    This software is distributed in the hope that it will be useful, but
  28.  *    WITHOUT ANY WARRANTY; without even the implied warranty of
  29.  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  30.  *    GNU General Public License for more details.
  31.  *
  32.  *      For a copy of the GNU General Public License
  33.  *    write to the Free Software Foundation, 675 Mass Ave,
  34.  *    Cambridge, MA  02139, USA.
  35.  *
  36.  */
  37.  
  38. #include <stdlib.h>
  39. #include "/include/types.h"
  40. #include "/include/errors.h"
  41. #include "/include/control.h"
  42. #include "/include/displaymap.h"
  43. #include "/include/transformation.h"
  44. #include "/include/viewperstrans.h"
  45. #include "/include/raster.h"
  46. #include "/include/database.h"
  47. #include "/include/display.h"
  48.  
  49. static UBYTE error;
  50.  
  51. UWORD width,height,x_center,y_center;
  52.  
  53.      /* Open the render environment. */
  54.  
  55. UBYTE opengraphics(UWORD swidth,UWORD sheight,UWORD *coltable,UBYTE *modelpath)
  56.  
  57. {       
  58.     /* Construct screen info. */
  59.     
  60.     width = swidth;
  61.     height = sheight;
  62.     x_center = swidth >> 1;
  63.     y_center = sheight >> 1;
  64.  
  65.     /* Open the display screen. */
  66.  
  67.     if((error = opendisplay(coltable,swidth,sheight,1)) != SUCCESS)
  68.        return(error);
  69.     
  70.         /* Open the model database. */
  71.     
  72.     opendatabase(modelpath);
  73.     
  74.         /* Open the perspective transformation system. */
  75.     
  76.     if((error = openviewperstrans())!=SUCCESS) {
  77.        closedisplay();
  78.        return(error);
  79.     }
  80.     
  81.         /* Open the transformation system. */
  82.     
  83.     if((error = opentransformation())!=SUCCESS) {
  84.        closeviewperstrans();
  85.        closedisplay();
  86.        return(error);
  87.     }    
  88.  
  89.     return(SUCCESS);
  90. }     
  91.  
  92.      /* Run through the graphics pipeline. */
  93.  
  94. void displaygraphics()
  95.  
  96. {
  97.     traversedisplaymap();    /* Update object verticies for objects that have changed. */
  98.     transformvert();        /* Transform all of the verticies to the new view and clip. */
  99.     scanconvert();        /* Draw the raster list of polys in the current view. */
  100.     showgraphics();        /* Switch the double buffer screen. */
  101.     clearscreen();        /* Clear the new screen. */
  102. }
  103.  
  104.      /* Close down the environment. */
  105.      
  106. void closegraphics()
  107.  
  108. {   
  109.     cleardisplaymap();    
  110.     closetransformation();
  111.     closeviewperstrans();  
  112.     closedatabase();
  113.     closedisplay();    
  114. }
  115.